/**
*      author: Y_Yao
*      created: 2024-12-02 23:48:04
**/

#include<bits/stdc++.h>

using namespace std;
#define int LL
using LL = long long;
const LL LLINF = 1e18;
const int INF = 0x3f3f3f3f;
const int N = 1e3 + 7;
int n;
int a[N];

void solve()
{
    cin >> n;
    int count = 0;
    int ret = 0;
    unordered_map<int,int> hash;
    for(int i = 1;i <= n;i++)
    {
        cin >> a[i];
        if(hash.count(a[i]) == 0) count++;
        hash[a[i]]++;
    }

    int num = (n + 1) / 2;
    vector<pair<int,int>> v;
    int count1 = 0;
    for(auto e : hash)
    {
        v.push_back({e.second,e.first});
    }

    sort(v.begin(),v.end());

    // if(num >= count)
    // {   
    //     ret += count + count1;
    //     int tn = num - count;
    //     int i = 0;
    //     while(tn > 0)
    //     {
    //         if(v[i].second >= 2)
    //         {
    //             ret += v[i].second - 1;
    //             tn = tn - v[i].second + 1;
    //         }
    //         i++;
    //     }
    // }
    // else
    // {
    //     int tn = num;

    // }

    //先拿颜色种类
    int i = 0;
    while(i < count)
    {
        ret++;
        v[i].first -= 1;
        if(v[i].first == 0) ret++;
        i++;
        num--;
        if(num == 0)
        {
            cout << ret << endl;
            return;
        }
    }

    i = 0;
    while(num > 0)
    {
        if(v[i].first == 0)
        {
            i++;
            continue;
        }
        while(v[i].first != 0)
        {
            v[i].first--;
            num--;
            if(num == 0)
            {
                break;
            }
        }
        if(v[i].first == 0)
        {
            ret++;
        }
    }

    cout << ret << endl;

}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}
